<template>
	<div class="zhengtuojianhuo">
		<van-nav-bar :fixed="true" class="navBar" title="结束容器" left-arrow @click-left="$router.go(-1)"></van-nav-bar>

		<div class="goodsFromWarp">
				<div class="goodsInputWarp">
						<div class="goodsInputLabel">
							<div class="goodsInputBorder"></div>
							<div class="skuName">波次单号：</div>
						</div>

						<div class="skuNoInput">
							{{jieshuData[0].bill}}
						</div>
				</div>

				<div class="goodsInputWarp">
						<div class="goodsInputLabel">
							<div class="goodsInputBorder"></div>
							<div class="skuName">门店：</div>
						</div>

						<div class="skuNoInput">
							{{jieshuData[0].ck_storeid}} {{jieshuData[0].ck_storeid >''?'-':''}}{{jieshuData[0].storename}}
						</div>
				</div>


				<div class="goodsInputWarp">
						<div class="goodsInputLabel" style="width:35%;">
							<div class="goodsInputBorder"></div>
							<div class="skuName" style="width: 120px;">拣货标签：</div>
						</div>
						<van-field
							 class="skuInput"
							 v-model="jhrqid"
							 placeholder="请填写拣货标签"
						 />
				</div>

				<div class="savefooterBtn" style="margin-bottom: 0px;">
					<van-button style="margin-left:20px;" type="info"  @click="savejieShuClickBtn()">任务完成</van-button>
				</div>

		</div>

		<data-table
			:table-data="jieshuData"
			:columns="jieshuColumns"
			height="calc(100vh - 210px)"
		/>

	</div>
</template>

<script>
import DataTable from '@/components/DataTable.vue'

export default {
  name: 'storejieshu',
  components: {
    DataTable
  },
  data() {
    return {
			editForm:{},
			jieshuData:[
				{
					bill:'',
					ck_storeid:'',
					storename:'',
				}
			],
			isdisabled:'',
			jhrqid:'',
			hzyjtotqty:'',
			jieshuColumns: [
				{ prop: 'cwno', label: '仓位', width: '100'},
				{ prop: 'bill', label: '任务号', width: '135'},
				{ prop: 'barcode', label: '条码', width: '130'},
				{ prop: 'subsname', label: '商品', width: '230' },
				{ prop: 'unit', label: '箱装', width: '80' },
				{ prop: 'pack', label: '箱数', width: '80' },
				{ prop: 'qty', label: '散数', width: '80' },
				{ prop: 'yjtotqty', label: '要货数量', width: '100' },
				{ prop: 'jhtotqty', label: '拣货总数', width: '100' }
			],
		};
  },
    // 添加 activated 钩子，确保每次进入页面都重新加载数据
    activated() {
      console.log("结束数据")
      this.editForm = JSON.parse(this.$route.query.editForm)
      this._getSku()
    },
  //
	computed: {
	   ryuser: function(){
	     return this.GWO(true).gUSER;
	   }
	},
  methods: {
		savejieShuClickBtn(){
			console.log(this.editForm.bill)
			var _self = this;
			var ldemodata = [{retval:0, errmsg:'返回数据集'},]
			this.MYPOST({
					'method':'dgate',
					'pname':'f_wmsa_y_jianhuo',
					'i':this.FNULLE([
					'opmode','Y_ANDIAN_jsrq',
					'kqid', this.ryuser.kqid,
					'czyid',this.ryuser.operatorid,
					'bill', this.jieshuData[0].bill,
					'jhrqid', this.jhrqid,
					'hzyjtotqty', this.hzyjtotqty,
				])
				}, '结束容器提交',true, ldemodata, function(ret_obj, ret_iserr,ret_errmess,ret_oldresp){
				if(ret_iserr){ //传入的true参数,理论上不会有此回调了
					_self.$toast.fail('查询失败')
					_self.$store.commit('hideLoading');
				}else{
					var rtn_json_obj = null;
					_self.$store.commit('hideLoading');
					if(ret_obj != null){ rtn_json_obj = ret_obj; //返回的接口可以直接解析的情况
					}else{  rtn_json_obj = _self.arr2Obj(ret_oldresp.data); //非标准的dgate接口,返回的一个不兼容的处理
					}
					console.log("得到结束容器提交")
					console.log(rtn_json_obj)
					if(rtn_json_obj[0].ret_ret == '-1'){
						_self.$toast.fail(rtn_json_obj[0].ret_mess)
						return
					}else{
						_self.$toast.fail(rtn_json_obj[0].ret_mess)
						_self.$router.go(-1)
					}
				}
			});
		},
		_getSku(){
			console.log(this.editForm.bill)
			var _self = this;
			var ldemodata = [{retval:0, errmsg:'返回数据集'},]
			this.MYPOST({
					'method':'dgate',
					'pname':'f_wmsa_y_jianhuo',
					'i':this.FNULLE([
					'opmode','Y_ANDIAN_jsrq_qry',
					'kqid', this.ryuser.kqid,
					'czyid',this.ryuser.operatorid,
					'bill', this.editForm.bill,
				])
				},'结束容器',true, ldemodata, function(ret_obj, ret_iserr,ret_errmess,ret_oldresp){
				if(ret_iserr){ //传入的true参数,理论上不会有此回调了
					_self.$toast.fail('查询失败')
					_self.$store.commit('hideLoading');
				}else{
					var rtn_json_obj = null;
					_self.$store.commit('hideLoading');
					if(ret_obj != null){ rtn_json_obj = ret_obj; //返回的接口可以直接解析的情况
					}else{  rtn_json_obj = _self.arr2Obj(ret_oldresp.data); //非标准的dgate接口,返回的一个不兼容的处理
					}
					console.log("得到结束容器")
					console.log(rtn_json_obj)
					_self.jieshuData = rtn_json_obj
					_self.hzyjtotqty = _self.jieshuData[0].hzyjtotqty
          _self._getSkuIndex()
				}
			});
		},
    _getSkuIndex(){
      console.log(this.editForm.bill)
			var _self = this;
			var ldemodata = [{retval:0, errmsg:'返回数据集'},]
			this.MYPOST({
					'method':'dgate',
					'pname':'f_wmsa_y_jianhuo',
					'i':this.FNULLE([
					'opmode','Y_ANDIAN_jsrq_qry',
					'kqid', this.ryuser.kqid,
					'czyid',this.ryuser.operatorid,
					'bill', this.jieshuData[0].bill,
				])
				},'结束容器索引',true, ldemodata, function(ret_obj, ret_iserr,ret_errmess,ret_oldresp){
				if(ret_iserr){ //传入的true参数,理论上不会有此回调了
					_self.$toast.fail('查询失败')
					_self.$store.commit('hideLoading');
				}else{
					var rtn_json_obj = null;
					_self.$store.commit('hideLoading');
					if(ret_obj != null){ rtn_json_obj = ret_obj; //返回的接口可以直接解析的情况
					}else{  rtn_json_obj = _self.arr2Obj(ret_oldresp.data); //非标准的dgate接口,返回的一个不兼容的处理
					}
					console.log("得到结束容器索引")
					console.log(rtn_json_obj)
					_self.jieshuData = rtn_json_obj
					_self.hzyjtotqty = _self.jieshuData[0].hzyjtotqty
				}
			});
    }
  },
  mounted() {
		 console.log("结束数据")
		 this.editForm =JSON.parse(this.$route.query.editForm)
		 console.log(this.editForm)
		 this._getSku();
  },
};
</script>

<style lang="scss" scoped>
	// 引入公共样式
	@import '@/assets/css/base.scss';
	@import '@/assets/css/input.scss';
	div.zhengtuojianhuo{
		padding-top: 50px;
	}

	.table-wrapper {
		margin: 10px 16px;
	}

	.savefooterBtn{
		display: flex;
		justify-content: flex-end;
		margin-top: 20px;
		button{
			border-radius: 20px;
			width: 100px;
			height: 35px;
		}
	}

</style>
